package com.ruoyi.examination.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.examination.domain.PaperConfigGroup;
import com.ruoyi.examination.service.IPaperConfigGroupService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 题组与试卷设置Controller
 * 
 * @author hcc
 * @date 2025-10-21
 */
@RestController
@RequestMapping("/paperConfigGroup")
public class PaperConfigGroupController extends BaseController
{
    @Autowired
    private IPaperConfigGroupService paperConfigGroupService;

    /**
     * 查询题组与试卷设置列表
     */
    @RequiresPermissions("examination:paperConfigGroup:list")
    @GetMapping("/list")
    public TableDataInfo list(PaperConfigGroup paperConfigGroup)
    {
        startPage();
        List<PaperConfigGroup> list = paperConfigGroupService.selectPaperConfigGroupList(paperConfigGroup);
        return getDataTable(list);
    }

    /**
     * 导出题组与试卷设置列表
     */
    @RequiresPermissions("examination:paperConfigGroup:export")
    @Log(title = "题组与试卷设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PaperConfigGroup paperConfigGroup)
    {
        List<PaperConfigGroup> list = paperConfigGroupService.selectPaperConfigGroupList(paperConfigGroup);
        ExcelUtil<PaperConfigGroup> util = new ExcelUtil<PaperConfigGroup>(PaperConfigGroup.class);
        util.exportExcel(response, list, "题组与试卷设置数据");
    }

    /**
     * 获取题组与试卷设置详细信息
     */
    @RequiresPermissions("examination:paperConfigGroup:query")
    @GetMapping(value = "/{paperConfigGroupId}")
    public AjaxResult getInfo(@PathVariable("paperConfigGroupId") String paperConfigGroupId)
    {
        return success(paperConfigGroupService.selectPaperConfigGroupByPaperConfigGroupId(paperConfigGroupId));
    }

    /**
     * 新增题组与试卷设置
     */
    @RequiresPermissions("examination:paperConfigGroup:add")
    @Log(title = "题组与试卷设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PaperConfigGroup paperConfigGroup)
    {
        return toAjax(paperConfigGroupService.insertPaperConfigGroup(paperConfigGroup));
    }

    /**
     * 修改题组与试卷设置
     */
    @RequiresPermissions("examination:paperConfigGroup:edit")
    @Log(title = "题组与试卷设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PaperConfigGroup paperConfigGroup)
    {
        return toAjax(paperConfigGroupService.updatePaperConfigGroup(paperConfigGroup));
    }

    /**
     * 删除题组与试卷设置
     */
    @RequiresPermissions("examination:paperConfigGroup:remove")
    @Log(title = "题组与试卷设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{paperConfigGroupIds}")
    public AjaxResult remove(@PathVariable String[] paperConfigGroupIds)
    {
        return toAjax(paperConfigGroupService.deletePaperConfigGroupByPaperConfigGroupIds(paperConfigGroupIds));
    }
}
